#ifndef BOSS_Afterburner_TokenizedLine_H
#define BOSS_Afterburner_TokenizedLine_H

#include "TString.h"
#include <vector>

/// @addtogroup Afterburner_objects
/// @{

/// @author   Remco de Boer 雷穆克 (r.e.deboer@students.uu.nl or remco.de.boer@ihep.ac.cn)
/// @date     April 12th, 2019
class TokenizedLine
{
public:
  TokenizedLine(const TString& input, const char* delim = ",");
  void SetLineAndTokenize(const TString& line);

  const Int_t    GetNSegments() const;
  const TString& GetSegment(Int_t i) const;
  const char*    GetDelimiter() const { return fDelimiter.Data(); }

  TString BuildMergedSegments(Int_t from, Int_t to) const;

private:
  TString              fLine;
  const TString        fDelimiter;
  const Ssiz_t         fDelimWidth;
  std::vector<TString> fArrayOfSegments;

  void   InsertSpaces();
  void   SetArrayOfSegments();
  Bool_t IndexOutOfRange(const Int_t& i) const;
  Int_t  FlipIndex(Int_t i) const;
};

/// @}
#endif